package com.slj.service.impl;

import com.slj.entity.Class;
import com.slj.mapper.ClassMapper;
import com.slj.service.ClassService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
@RequiredArgsConstructor
public class ClassServiceImpl implements ClassService {
    private final ClassMapper classMapper;

    @Override
    public Class createClass(Class clazz) {
        classMapper.insert(clazz);
        return clazz;
    }

    @Override
    public Class updateClass(Class clazz) {
        classMapper.updateByPrimaryKey(clazz);
        return clazz;
    }

    @Override
    public void deleteClass(Integer classId) {
        classMapper.deleteByPrimaryKey(classId);
    }

    @Override
    public Class getClassById(Integer classId) {
        return classMapper.selectByPrimaryKey(classId);
    }

    @Override
    public Class getClassByName(String className) {
        return classMapper.selectByClassName(className);
    }

    @Override
    public List<Class> getAllClasses() {
        return classMapper.selectAll();
    }
}